<script>
	import Vue from 'vue'
	window.config = {
//			api: 'http://172.16.201.127:8080/',									//小彭 api 地址
		//	api: 'http://172.16.1.69:8080/exchange-mobile/',					//69 api 地址
		api: 'https://www.vaniswdq.com/', //93 api 地址
//		api: 'https://lhang.com/',									//lhang api 地址
		source: '2', //h5 请求必带的一个状态
//		socket_host: 'wss://mobile.lhang.com/ws/transport', //lhang socket 地址
//		  socket_host: 'ws://172.16.1.69:8080/exchange-mobile/transport',		//69 socket 地址
//			socket_host: 'ws://172.16.1.93/ws/transport',						//93 socket 地址
			socket_host: 'ws://lhang.radarwin.com/ws/transport',				//93 socket 地址
//			socket_host: 'ws://172.16.5.200:8080/transport',						//小彭 socket 地址
	}

	//	Vue.prototype.lh_config = config;

	Vue.prototype.lh_http = function(type, url, params) {
		var q;
		var result;
		q = $.Deferred();
		let _url = config.api + url
		if(type == 'post' || type == 'POST') {
			$.ajax(_url, {
				type: 'post',
				data: params,
				dataType: "json",
				crossDomain: true,
				headers: {
					//					'Content-Type': 'application/x-ww-form-urlencoded',
				},
				success: function(data, textStatus, request) {
					if(data.status == 0) {
						result = {
							data: data.dataWrapper,
							status: true,
						}
					} else {
						result = {
							data: data.msg,
							status: false,
						}
					}
					q.resolve(
						result,
					);
				},
				error: function(e) {
					q.reject(e);
					console.log(e)
				}
			})
		} else {
			$.ajax(_url, {
				type: 'get',
				data: params,
				dataType: "json",
				crossDomain: true,
				headers: {
					//					'Content-Type': 'application/x-ww-form-urlencoded',
				},
				success: function(data, textStatus, request) {
					if(data.status == 0) {
						result = {
							data: data.dataWrapper,
							status: true,
						}
					} else {
						result = {
							data: data.msg,
							status: false,
						}
					}
					q.resolve(
						result,
					);
				},
				error: function(e) {
					q.reject(e);
					console.log(e)
				}
			})
		}
		return q.promise();
	}
	Vue.prototype.GetRequest=function(){
		var url = "?"+location.hash.split('?')[1]; //获取url中"?"符后的字串
	    var theRequest = new Object();
	    if (url.indexOf("?") != -1) {
	        var str = url.substr(1);
	        var strs = str.split("&");
	        for(var i = 0; i < strs.length; i ++) {
	            theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
	        }
	    }
	    return theRequest;
	}
	Vue.prototype.setpage=function(id,currentPage,total,pageTotal,size){
	    var page = '';
	    page += '<div class="footer">';
	    page += '<span><span id="apply17">当前页：第</span>'+currentPage+'<span id="apply18">页 共</span>'+pageTotal+'<span id="apply19">页</span></span>';
	    page += '<ul class="pagination pagination-lg">';
	
	    if(currentPage == 1){
	        page += '<li><a href="#">&laquo;</a></li>';
	    }else{
	        page += '<li>';
	        page += '<a href="javascript:getList('+(currentPage-1)+')">&laquo;</a>';
	        page += '</li>';
	    }
	
	    var arry = [1,2,3,4,5,6,7];
	    if(currentPage>arry[6]&&currentPage<=pageTotal){
	        for(var i=0;i<arry.length;i++){
	            arry[i]+=7;
	        }
	    }
	
	    for(var j=0;j<arry.length;j++){
	        var i = arry[j];
	        if(i>pageTotal){break};
	        if(currentPage == i){
	            page += '<li>';
	            page += '<a class="footerCurrent" href="javascript:getList('+(i)+')">'+i+'</a>';
	            page += '</li>';
	        }else{
	            page += '<li>';
	            page += '<a href="javascript:getList('+(i)+')">'+i+'</a>';
	            page += '</li>';
	        }
	    }
	
	    //下一页
	    if(currentPage == pageTotal || 0 == pageTotal) {
	        page += '<li> ';
	        page += '<a href="#">&raquo;</a>';
	        page += '</li>';
	    }else{
	        page += '<li>';
	        page += '<a href="javascript:getList('+ (currentPage*1+1)+')">&raquo;</a>';
	        page += '</li>';
	    }
	    page += '</ul></div></div>';
	    $("#"+id).html(page);
	    $("#currentPage").text(currentPage);
	}
</script>